<?php

require("config.php");

// This function will print HTML to represent the integer value passed
// in using the number images in the directory specified by $numdir with
// a height specified by the global $height.
//
// Note that $numdir only needs to contain 0.png, 1.png, ... 9.png. Larger
// numbers will be made by concatenating these. 
//
// This assumes integers. Any fractional part of a number passed will be
// discarded and only the integer part shown (without rounding).
function show_number($num, $height=-1)
{
	print get_number_html($num, $height);
}

function get_number_html($num, $height=-1)
{
	global $def_height;
	global $numdir;
	
	if($height == -1)$height = $def_height;

	// Get order of magnitude of number to print
	$order = floor(log10($num));
	
	if($order<0)$order=0;

	// Loop over digits
	$ret_str = "";
	for($i=$order; $i>=0; $i--){
		
		// Get digit of interest in one's spot
		$val = floor($num/pow(10,$i));
		
		// Remove values from digits greater than this one
		$digit = $val - (10.0*floor($val/10.0));
		
		$ret_str .= "<img height='$height' src='$numdir/${digit}.png'>";
	}

	return $ret_str;
}


?>